#include <iostream>
#include <vector>
#include <algorithm>

int main(int argc, char const *argv[])
{

    std::vector<int> v{};
    for (int i = 0; i < 10; i++)
    {
        v.push_back(i);
    }

    std::for_each(v.begin(), v.end(), [](const int &i)
                  { std::cout << i << " "; });

    std::cout << std::endl;

    std::vector<int>::const_iterator it = std::find_if(v.begin(), v.end(), [](const int &i)
                                                       { return i % 2 == 0; });
    if (it != v.end())
    {
        std::cout << *it << std::endl;
    }
    else
    {
        std::cout << "没有找到呢" << std::endl;
    }

    std::vector<int> evenNumbers{};
    std::copy_if(v.begin(), v.end(), std::back_insert_iterator(evenNumbers), [](const int &i)
                 { return i % 2 == 0; });

    for (const int &i : evenNumbers)
    {
        std::cout << i << " ";
    }
    std::cout << std::endl;

    return 0;
}
